//
//  FriendsViewController.m
//  AdvertisementI
//
//  Created by mac on 16/5/19.
//  Copyright © 2016年 Apple inc. All rights reserved.
//

#import "FriendsViewController.h"

#import "Masonry.h"
#import "netWork.h"
#import "MAin.h"
#import "ZLSoloViewController.h"

@interface FriendsViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray * _titleTwoArray;
}
@property(nonatomic,  strong)UITableView *tableView;

@end

@implementation FriendsViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    _tableView = [[UITableView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.rowHeight = 80;
    [self.view addSubview:_tableView];


    
    _titleTwoArray = [[NSMutableArray alloc]init];
    [netWork scroll:^(NSArray *arr) {
        [_titleTwoArray setArray:arr];
        [_tableView reloadData];
    } type:@"app_loadPerson"];

  
    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _titleTwoArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *UIimage = @"Identifer";
    
    
    //为节省内存，获取之前的存在的tableViewCell
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UIimage];
    MAin * main =[_titleTwoArray objectAtIndex:indexPath.row];
    if( cell == nil ){
        //创建UITableViewCell对象，设置行的样式和别名
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UIimage];
        cell.textLabel.text = main.name;
        cell.textLabel.font = [UIFont systemFontOfSize:18];
        cell.textLabel.textColor =[UIColor blueColor];
        
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ZLSoloViewController *vc = [[ZLSoloViewController alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    MAin * main =[_titleTwoArray objectAtIndex:indexPath.row];
    if (indexPath.row == 0) {
        vc.myTitle = main.name;
        vc.string  = @"http://47.88.76.185/APP1/terman.html";
    }else if (indexPath.row == 1){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Hewlett-Packard.html" ;
    }else if (indexPath.row == 2){
        vc.myTitle = main.name;
        vc.string =@"http://47.88.76.185/APP1/Shokley.html" ;
    }else if (indexPath.row == 3){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Robert_Noyce.html";
    }else if (indexPath.row == 4){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Eugene_Kleiner.html";
    }else if (indexPath.row == 5){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Arthur_Rock.html";
    }else if (indexPath.row == 6){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Dennis.html";
    }else if (indexPath.row == 7){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Steve_Wozniak.html";
    }else if (indexPath.row == 8){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Stanford_University.html";
    }else if (indexPath.row == 9){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Larry_Ellison.html";
    }else if (indexPath.row == 10){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Dougla_Engelbart.html";//http://47.88.76.185/sx/html2/电子元器件.html
    }else if (indexPath.row == 11){
        vc.myTitle = main.name;
        vc.string = @"http://47.88.76.185/APP1/Jack_Kilby.html";
    }
    
    [self.navigationController pushViewController:vc animated:YES];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
